import torch
import numpy as np
import scipy.io as sio
import numpy as np
from .main_net import Views

def load_ACM(v=2):

    data = sio.loadmat("../data/ACM3025.mat")
    view1 = data['PAP'].astype(np.float32)
    view2 = data['PLP'].astype(np.float32)
    fea = data['feature']
    label = data['label']
    n, c = label.shape
    label = np.argmax(label, axis=1)
    views = Views(v, view1, view2)
    v = views.v
    x = torch.from_numpy(fea).float().cuda()
    return n, c, label, views, v, x


def load_DBLP(v=2):
    data = sio.loadmat("../data/DBLP.mat")
    view1 = data['PAP'].astype(np.float32)
    view2 = data['PCP'].astype(np.float32)
    view3 = data['PTP'].astype(np.float32)
    fea = data['feature']
    label = data['label']
    n, c = label.shape
    label = np.argmax(label, axis=1)
    views = Views(v, view1, view2, view3)
    v = views.v
    x = torch.from_numpy(fea).float().cuda()
    return n, c, label, views, v, x


def load_IMDB(v=2):
    data = sio.loadmat("../data/imdb5k.mat")
    view1 = data['MDM'].astype(np.float32)
    view2 = data['MAM'].astype(np.float32)
    fea = data['feature']
    label = data['label']
    n, c = label.shape
    label = np.argmax(label, axis=1)
    views = Views(v, view1, view2)
    v = views.v
    x = torch.from_numpy(fea).float().cuda()
    return n, c, label, views, v, x

def load_Freebase(v=2):
    data = sio.loadmat("../data/Freebase.mat")
    view1 = data['MDM'].toarray().astype(np.float32)
    view2 = data['MWM'].toarray().astype(np.float32)
    fea = data['MAM'].toarray().astype(np.float32)
    label = data['label'].squeeze()
    n, c = label.shape[0], len(np.unique(label))
    views = Views(v, view1, view2)
    v = views.v
    x = torch.from_numpy(fea).float().cuda()
    return n, c, label, views, v, x